// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import store from './store'
import axios from 'axios'
import 'babel-polyfill' // 兼容

import 'element-ui/lib/theme-chalk/index.css';
// import './theme/index.css'
import { 
	Container,
	Header,
	Aside,
	Main,
	Menu,
	Submenu,
	MenuItem,
	Form,
	FormItem,
	Input,
	Button,
	ButtonGroup,
	Checkbox,
	Row,
	Col,
	Breadcrumb,
	BreadcrumbItem,
	Table,
	TableColumn,
	Pagination,
	Loading,
	MessageBox,
	Message,
	Select,
	Option,
	OptionGroup,
	Dialog,
	Cascader,
	Upload,
	DatePicker,
	Notification,
	Tabs,
	TabPane,
} from 'element-ui';

Vue.use(Container);
Vue.use(Header);
Vue.use(Aside);
Vue.use(Main);
Vue.use(Menu);
Vue.use(Submenu);
Vue.use(MenuItem);
Vue.use(Form);
Vue.use(FormItem);
Vue.use(Input);
Vue.use(Button);
Vue.use(ButtonGroup);
Vue.use(Checkbox);
Vue.use(Row);
Vue.use(Col);
Vue.use(Breadcrumb);
Vue.use(BreadcrumbItem);
Vue.use(Table);
Vue.use(TableColumn);
Vue.use(Pagination);
Vue.use(Loading);
Vue.use(Select);
Vue.use(Option);
Vue.use(OptionGroup);
Vue.use(Dialog);
Vue.use(Cascader);
Vue.use(Upload);
Vue.use(DatePicker);
Vue.use(Tabs);
Vue.use(TabPane);


Vue.use(Loading.directive);

Vue.prototype.$loading = Loading.service;
// Vue.prototype.$msgbox = MessageBox;
// Vue.prototype.$alert = MessageBox.alert;
Vue.prototype.$confirm = MessageBox.confirm;
Vue.prototype.$prompt = MessageBox.prompt;
Vue.prototype.$notify = Notification;
Vue.prototype.$message = Message;

Vue.prototype.$axios = axios;
Vue.config.productionTip = false;

router.beforeEach((to, from, next) => {
	//NProgress.start();
	let crocUser = JSON.parse(window.localStorage.getItem('crocUser'));
	if (crocUser) {
		store.state.crocUser = crocUser;
	}
	next();
})
// 移除数组某一项
Array.prototype.indexOf = function(val) { 
	for (var i = 0; i < this.length; i++) { 
	if (this[i] == val) return i; 
	} 
	return -1; 
};
Array.prototype.remove = function(val) { 
	var index = this.indexOf(val); 
	if (index > -1) { 
	this.splice(index, 1); 
	} 
};
/* eslint-disable no-new */
new Vue({
	el: '#app',
	router,
	store,
	components: { App },
	template: '<App/>'
})